#pragma once

#include <fstream>
#include <functional>
#include <algorithm>

using std::tstring;
using std::tifstream;

class CLogFile
{
public:
	CLogFile( void );
	virtual ~CLogFile(void);

	typedef struct tagPriceRecord
	{
		tstring	strTime;
		tstring	strCount;
		tstring	strPrice;
		tstring	strFlag;
		tstring	strBidPrice;
		tstring	strAskPrice;

	}PRICE_RECORD;

	bool Open( const tstring& strFile );
	bool Eof( void );
	virtual bool PickPrice( PRICE_RECORD& rcdPrice );

private:
	bool ReadLine( tstring& strLine );
	virtual bool ParseLine( const tstring& strLine, PRICE_RECORD& rcdPrice ) const;

	static void DelSpace( tstring& strLine );
private:
	tifstream	m_iFile;
};

inline void CLogFile::DelSpace( tstring& strLine )
{
	std::tstring::iterator iter =  std::remove_if( strLine.begin(), strLine.end(), std::bind1st( std::equal_to<TCHAR>(), _T(' ')));
	strLine.erase( iter, strLine.end() );
}

inline bool CLogFile::Eof( void )
{
	return m_iFile.eof();
}